#include <stdio.h>
#include <stdlib.h>
int main()
{
	int x,a,b,c,d,e;
	printf("Please enter number:");
	scanf("%d",&x);
	while(x<0||x>99999)
	{
		printf("Error! retry!\n Please enter number:");
		scanf("%d",&x);
	 } 
	 a=x/10000;
	 b=x/1000;
	 c=x/100;
	 d=x/10;
	 e=x-d*10;
	 if(a>=1&&a<=9)
	 {
	 	printf("%d is 5 bits!\n",x);
	 	printf("%d %d %d %d %d\n",a,b-a*10,c-b*10,d-c*10,e);
	 	printf("%d %d %d %d %d\n",e,b-a*10,c-b*10,d-c*10,a);
	 }
	 else if (b>=1&&b<=9)
	 {
	 		printf("%d is 4 bits!\n",x); 
	 			printf("%d %d %d %d\n",b,c-b*10,d-c*10,e);
	 		printf("%d %d %d %d\n",e,d-c*10,c-b*10,b);
	 }
	 else if (c>=1&&c<=9)
	 {
	 	printf("%d is 3 bits!\n",x);
		  printf("%d %d %d %d\n",c,d-c*10,e);
		  printf("%d %d %d %d\n",e,d-c*10,c);
	}
	 else if (d>=1&&d<=9)
	 {
	 	printf("%d is 2 bits!\n",x);
	 		 printf("%d %d\n",e,d);
	 	}
	 	else{
	 		printf("%d is 1 bits!\n",x);
	 		printf("%d\n",x);
		 }
		 system("pause");
		 return 0;
}
